package com.pllandxzx.controller;

import com.pll.dto.ResponseDto;
import com.pllandxzx.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author 小鹿
 * @Date 2025/6/13 15:05
 */

@Tag(name = "用户管理")
@RestController
@RequestMapping("/user")
public class UserController
{
    @Autowired
    private UserService userService;

    @Operation(summary = "获取所有用户信息", description = "可根据账号或手机号获取所有用户信息")
    @GetMapping("/list")
    public ResponseDto list(
            @RequestParam("page") Integer page,
            @RequestParam("pageSize") Integer pageSize,
            @RequestParam("account") String account,
            @RequestParam("phone") String phone){
        return userService.list(page,pageSize,account,phone);
    }

    @Operation(summary = "修改状态", description = "根据用户id修改这个账号的状态是否禁用")
    @PutMapping("/status/{userId}")
    public ResponseDto status(@PathVariable("userId")Integer userId){
        return userService.status(userId);
    }

    @Operation(summary = "修改密码", description = "根据用户id和新密码修改账号密码")
    @PutMapping("/updatePassword/{userId}/{newPassword}")
    public ResponseDto updatePassword(@PathVariable("userId")Integer userId,@PathVariable("newPassword")String newPassword){
        return userService.updatePassword(userId,newPassword);
    }

    @Operation(summary = "获取详情数据", description = "根据用户id获取用户详情数据，包含优惠券数据")
    @GetMapping("/detail/{userId}")
    public ResponseDto detail(@PathVariable("userId")Integer userId){
        return userService.detail(userId);
    }
}